﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using ProcessControl;
using System.Data;
using MyLib;

namespace ChengpiReport
{
    public partial class NewRequest : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            //添加提交事件
            ((ButtonList_TY)ButtonList1).BeforeSubmit += new System.ComponentModel.CancelEventHandler(NewRequest_BeforeSubmit);
        }

        //实现
        void NewRequest_BeforeSubmit(object sender, System.ComponentModel.CancelEventArgs e)
        {
            DataTable dt = DataAccess.Instance("BizDB").ExecuteDataTable("select  nvl(max(cast(substr(tnumber,15,4) as integer)),0) from PROC_CHENGPIREPORT");
            string no = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString();
            if (no.Length == 1)
            {

                no = "000" + no.ToString();
            }
            else if (no.Length == 2)
            {
                no = "00" + no.ToString();
            }
            else if (no.Length == 3)
            {
                no = "0" + no.ToString();
            }
            string now = DateTime.Now.ToString("yyyyMMdd");
            TNUMBER.Text = "bjty-" + now + "-" + no;
            fld_TNUMBER.Text = "bjty-" + now + "-" + no;
        }
    }
}